package com.example.brazil_project.util;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import com.example.brazil_project.parameter.Parameter;

import android.app.Activity;
import android.webkit.WebView;

public class FirstOpenUtil {

	/**
	 * 初涉化APP
	 */
	public static void intiAPP(Activity con,Object view){
		WebView webview = (WebView) view;
		List list = new ArrayList();
		//是否第一次打开文件
		list.add("first_opne");
		Map map = SharedPreferencesUtil.getSharedPreferencesData(con, "system_setting", list);
		//如果不是
		if(map==null || map.size()<=0){
			//创建系统信息表
			String createTablesql = "CREATE TABLE SystemInform_table (id INTEGER , title VARCHAR, content VARCHAR,CreateDate VARCHAR,username VARCHAR,isread VARCHAR,type VARCHAR,reply VARCHAR)";
			SQLiteDatabaseUtil.onCreateTable(createTablesql);
			//创建到货信息表(对于的信息id， 名字，产品路径，价格,品规,产品类型)
		    createTablesql = "CREATE TABLE ArriveInform_table (id INTEGER , "
		    				+ "title VARCHAR, "
		    				+ "content VARCHAR,"
		    				+ "CreateDate VARCHAR,"
		    				+ "username VARCHAR,"
		    				+ "isread VARCHAR,"
		    				+ "type VARCHAR,"
		    				+ "sender VARCHAR,"
		    				+ "ioc VARCHAR)";
			SQLiteDatabaseUtil.onCreateTable(createTablesql);
			createTablesql = "CREATE TABLE ArriveProduct_table (msg_id INTEGER ,"
					+ " name VARCHAR,"
					+ " imgUrl VARCHAR , "
					+ " price VARCHAR,"
					+ " specifications VARCHAR,"
					+ " productType VARCHAR ,"
					+ " product_id INTEGER,"
					+ " Stock VARCHAR)";
			SQLiteDatabaseUtil.onCreateTable(createTablesql);
//			//添加第一次打开软件的时间
		/*	if(Parameter.First_Time==null){
				Parameter.First_Time= DateUtil.dateFormat(new Date(), "yyyy-MM-dd HH:mm:ss");
			}	*/
			//修改成已经添加过了
			map.put("first_opne", "false");
			//设置第一次打开时间
			map.put("First_Time",DateUtil.dateFormat(new Date(), "yyyy-MM-dd HH:mm:ss"));
		}
		//设置服务器地址
		map.put("serverPath","http://192.168.191.1:8083/");
		//map.put("serverPath","http://120.24.159.176:8080/ebuyForBrazil/"); 
		SharedPreferencesUtil.setSharedPreferencesData(con, "system_setting", map);
		
	}
}
